﻿#region Usings

using System.Data.Entity.ModelConfiguration;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data.Configuration
{
    public class AdministrationMap : EntityTypeConfiguration<Administration>
    {
        public AdministrationMap()
        {
            ToTable("Administrations");
            HasKey(administration => administration.Id);

            Property(administration => administration.Name).IsRequired().HasMaxLength(30);

            HasMany(administration => administration.Tariffs).WithMany(tariff => tariff.Administrations).Map(
                m =>
                    {
                        m.ToTable("TariffAdministrations");
                        m.MapLeftKey("Administration_Id");
                        m.MapRightKey("Tariff_Id");
                    });
        }
    }
}